//
//  BLClothAlertViewController.m
//  blanket
//
//  Created by Mac on 2017/12/6.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "BLClothAlertViewController.h"

@interface BLClothAlertViewController ()
@property(nonatomic, strong) STButton                     *clearButton;
@property(nonatomic, strong) UIView                     *customView;
@end

@implementation BLClothAlertViewController

- (instancetype)init
{
    if (self == [super init]) {
        self.modalPresentationStyle = UIModalPresentationOverFullScreen;
    }
    return self;
}
#pragma mark --vc 生命周期
- (void)viewDidLoad{
    [super viewDidLoad];
    [self configSubView];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self show];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}
#pragma mark --subView
- (void)configSubView{
    __weak typeof(self) weakSelf =  self;
    self.clearButton = [[STButton alloc] initWithFrame:UIScreenFrame
                                                 title:nil
                                            titleColor:nil
                                             titleFont:0
                                          cornerRadius:0
                                       backgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.4]
                                       backgroundImage:nil
                                                 image:nil];
    [weakSelf.clearButton setClicAction:^(UIButton *sender) {
        [weakSelf dismiss];
    }];
    [self.view addSubview:_clearButton];
    
    self.customView = [[UIView alloc] initWithFrame:CGRectMake(0, UIScreenHeight, 329, 342)];
    self.customView.centerX = UIScreenWidth / 2;
    self.customView.top = UIScreenHeight;
    [self.clearButton addSubview:self.customView];
    
    UIImageView * imaegView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 329, 342)];
    imaegView.image = [UIImage imageNamed:@"暂无通知"];
    [self.customView addSubview:imaegView];
    
    
    NSString * title = @"《温馨提示》\n\n\n亲，如果月均闲置布草超过70%，我们将加收\"闲置布草管理费用\",您可以通过减少布草库存货正价洗送布草数量，来避免此费用的产生！";
    if (self.desString) {
        self.desString = [NSString stringWithFormat:@"《温馨提示》\n\n\n%@",self.desString];
    }else{
        self.desString = title;
    }
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(20, 150, self.customView.width - 40, 180)
                                                     text:self.desString
                                                textColor:BL_secendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    titleLable.numberOfLines = 0;
    titleLable.attributedText = [titleLable.text st_convertAttributeStringWithKeyWord:@"《温馨提示》" attributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:18]}];
    [self.customView addSubview:titleLable];

}
#pragma mark --Private Method
- (void)show{
    [UIView animateWithDuration:0.6
                          delay:0
         usingSpringWithDamping:0.6
          initialSpringVelocity:0.7
                        options:UIViewAnimationOptionLayoutSubviews
                     animations:^{
                         self.customView.centerY = UIScreenHeight / 2;
                     } completion:^(BOOL finished) {
                         
                     }];
}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.customView.top = UIScreenHeight;
        self.clearButton.alpha = 0;
    } completion:^(BOOL finished) {
        [self dismissViewControllerAnimated:NO completion:nil];
    }];
}
@end
